//非递减子序列 力扣491
//回溯算法 收集每一个节点作为答案 树层去重（使用unordered_set）
class Solution {
public:
	vector<vector<int>> ans;
	vector<int> path;
	void backtracking(vector<int> nums,int startindex)
	{
		if(path.size() >= 2)
			ans.push_back(path);
		unordered_set<int> uset;
		for(int i = startindex; i < nums.size(); i++)
		{
			if(uset.find(nums[i]) != uset.end() || !path.empty() && nums[i] < path.back())
				continue;
			path.push_back(nums[i]);
			uset.insert(nums[i]);
			backtracking(nums,i+1);
			path.pop_back();
		}
	}
	vector<vector<int>> findSubsequences(vector<int>& nums) {
		backtracking(nums,0);
		return ans;      
	}
};
